package com.gidas.server;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.gidas.client.ObjectTypeSerializable;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class ObjectTypeDB {
	
	@PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private String encodedKey;
	
	@Persistent
	private String name;
	
	@Persistent
	private int takesTimeMinutes;

	//gal padaryti porusi pagal paskirti visit, eat, dance, watch ... etc...
	
	public ObjectTypeDB(String encodedKey, String name, int takesTimeMinutes){
		this.encodedKey = encodedKey;
		this.name = name;
		this.takesTimeMinutes = takesTimeMinutes;
	}
	
	public ObjectTypeDB(ObjectTypeSerializable objectType)
	{
		this.encodedKey = objectType.getEncodedKey();
		this.name = objectType.getName();
		this.takesTimeMinutes = objectType.getTakesTimeMinutes();		
	}
	public ObjectTypeSerializable getObjectTypeSerializable()
	{
		ObjectTypeSerializable objectType = new ObjectTypeSerializable(encodedKey, name, takesTimeMinutes);
		return objectType;
	}
	
	public void updateObjectType(ObjectTypeSerializable objectType)
	{
		this.setName(objectType.getName());
		this.setTakesTimeMinutes(objectType.getTakesTimeMinutes());
	}
	

	//getters n setters
	public String getEncodedKey() 
	{
		return encodedKey;
    }
	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setTakesTimeMinutes(int takesTimeMinutes) {
		this.takesTimeMinutes = takesTimeMinutes;
	}
	public int getTakesTimeMinutes() {
		return takesTimeMinutes;
	}
	
	

}
